
*------------------------------------------------------------------------------*
* Special Case of ASPM: Bargaining of president and congress in the USA
*
* Version:	2016-06-13
* Changes:	2016-??-??: First release
*------------------------------------------------------------------------------*

* Drop "non-aligned party"
capture: drop if p101 == 61999



* HOUSE
* -----
gen zs1 = $ideology if p305>50 & p305 != .
by g101 g105, sort: egen house = max(zs1)
lab var house "Position of House (USA)"



* SENATE
* ------
gen zs2 = $ideology if p101==61320
gen zs3 = $ideology if p101==61620

by g101 g105, sort: egen democrats = max(zs2) 
by g101 g105, sort: egen republicans = max(zs3)

gen 	other_party = .
replace other_party = democrats		if p101 == 61620
replace other_party = republicans	if p101 == 61320


* Check if filibuster-proof majority 
gen		fbproofmaj = .
replace fbproofmaj = 1 if (p402 > 2/3*p403) & g105<=60	// before 1975
replace fbproofmaj = 1 if (p402 > 3/5*p403) & g105>60	// after 1975

* Check majority faction
by g101 g105, sort: egen zs4 = max(p402)
gen		majorfaction = .
replace majorfaction = 1 if p402 == zs4

* Check, how many senators from minority party are needed to arrive filibuster-proof majority
gen		raisesenators = .
replace raisesenators = (2/3*p403) - p402 if majorfaction==1 & g105<=60	// before 1975
replace	raisesenators = (3/5*p403) - p402 if majorfaction==1 & g105>60	// after 1975
	* Treat as "integer" persons
replace raisesenators = ceil(raisesenators)
replace raisesenators = 0 if fbproofmaj==1

* Filibuster = adjust position of Senate, i.e. the majority faction needs to compromise X times with the minority party
gen zs5	= .
replace zs5 = (p402*$ideology + raisesenators*other_party) / (2/3*p403)	if g105<=60	// before 1975
replace zs5	= (p402*$ideology + raisesenators*other_party) / (3/5*p403)	if g105>60	// after 1975
replace zs5 = $ideology if fbproofmaj==1
by g101 g105, sort: egen senate = max(zs5)
lab var senate "Position of Senate (USA)"



* CONGRESS
* --------
gen congress = (house + senate) / 2
lab var congress "Position of Congress, i.e. (House+Senate)/2 (USA)"



* ASPI
* ----
gen aspi_usa = 2/3*pres  +  1/3*congress
lab var aspi_usa "ASPI, i.e. 2/3*President + 1/3*Congress (USA)"

gen GOV_POS = .
replace GOV_POS = aspi_usa



* Cleansing
replace GOV_POS = . if g106 == 9

lab var GOV_POS "Position of government"

sort g101 g105 p101

capture: drop zs* democrats republicans other_party fbproofmaj majorfaction raisesenators



